package com.lqg.bookLibrary.pojo;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 
 * </p>
 *
 * @author prodigal_lqg
 * @since 2023-04-09 
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("borrow")
public class Borrow implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 借阅单唯一标识符
     */
    @TableId("borrow_id")
    private Long borrowId;

    /**
     * 下单用户的ID
     */
    @TableField("user_id")
    private Long userId;

    /**
     * 书籍id
     */
    @TableField("book_id")
    private Long bookId;

    /**
     * 借阅时间
     */
    @TableField("time_limit")
    private Integer timeLimit;

    /**
     * 是否延期
     */
    @TableField("delay")
    private Integer delay;

    /**
     * 是否逾期
     */
    @TableField("overdue")
    private Integer overdue;

    /**
     * 归还时间
     */
    @TableField("return_at")
    private LocalDateTime returnAt;


    /**
     * 创建时间
     */
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;


    /**
     * 最后更新时间
     */
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;


    public Borrow(Long userId, Long bookId, Integer timeLimit, Integer delay, Integer overdue) {
        this.userId = userId;
        this.bookId = bookId;
        this.timeLimit = timeLimit;
        this.delay = delay;
        this.overdue = overdue;
    }
}
